home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_11
/
9n11072a
< prev
next >
Wrap
Text File
|
1991-08-27
|
808b
|
23 lines
Listing 4:
# compiled using cc -O -S fib.c
_fib:
save %sp,-96,%sp # make space for new frame
cmp %i0,2 # determine if n<2
ble,a L77007
mov 1,%i0 # annuled if branch not taken
call _fib,1
sub %i0,2,%o0 # determine n-2
mov %o0,%i5 # copy fib(n-2) result
call _fib,1
sub %i0,1,%o0 # determine n-1
add %o0,%i5,%o0 # add fib(n-2) and fib(n-1)
mov %o0,%i0 # result in %i0 (%o0 of caller)
L77007:
ret
restore # return frame registers to stack